package org.myspringframework.core.io;

public class DefaultResourceLoader implements ResourceLoader {

    @Override
    public Resource getResource(String location) {
        if(location==null||location==""){
            throw new RuntimeException("文件地址为空！");
        }
        if (location.startsWith(CLASSPATH_URL_PREFIX)) {
            //为classpath下的文件信息
            return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()));
        }
        else {
            //为文件
            return new FileSystemResource(location);
        }
    }

}